package com.vogue.supplymall.admin.business.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;

import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

/**
 * The type Scheduled config.
 *
 * @aouthor: zhangliang
 * @date: Create in 2018-05-25
 */
@Configuration
public class ScheduledConfig implements SchedulingConfigurer {
    @Override
    public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) {
        scheduledTaskRegistrar.setScheduler(setTaskExecutors());
    }

    /**
     * Sets task executors.
     *
     * @return the task executors
     */
    @Bean
    public Executor setTaskExecutors() {
        return Executors.newScheduledThreadPool(10); // 3个线程来处理。
    }

}